import React from 'react'

import MenuItem from "./MenuItem"

export default function Menu(props) {
  const {permits, children} = props

  const menu = ()=>{
    let ui
    if(children){
      ui = <ul>{children.map(c=>{
        const itemProps = {permits, ...c}
        return <MenuItem key={c.id} {...itemProps} />
      })}</ul>
    }else{
      ui = <MenuItem {...permits} />
    }
    return ui
  }

  return (
    menu()
  )
}
